/**
 * 
 */
package com.zhiteng.quartz;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.zhiteng.entity.ActualNode;
import com.zhiteng.entity.Teacher;
import com.zhiteng.mapper.ActualNodeMapper;
import com.zhiteng.service.SmartCampusApiService;
import com.zhiteng.service.TeacherService;

/**  
* <p>Title: SendMsg.java</p>  
* <p>Description: 定时发消息</p>  
* @author dragon  
* @date 2018年12月31日  
* @version 1.0  
*/
@Component("sendMsg")
public class SendMsg {
	@Autowired
	private SmartCampusApiService smartCampusApiService;
	@Autowired
	private ActualNodeMapper actualNodeMapper;
	@Autowired
	private TeacherService teacherService;
	
	//	每天固定时间提醒调课的老师上课
	public void remindToClass()  {
		List<ActualNode> actualNodeList = actualNodeMapper.queryActualNodeListToday();
		if(actualNodeList!=null && !actualNodeList.isEmpty()) {
			for (ActualNode actualNode : actualNodeList) {
				Teacher teacher = teacherService.queryTeacherById(actualNode.getTeacherId());
				if(teacher==null) continue;
				Map<String,String> data = new HashMap<>();
				data.put("wxuserid",teacher.getWxuserid()); 
				data.put("content","因调课原因，今天"+actualNode.getGradeName()+actualNode.getClassName()+"第"+actualNode.getCourseNum()+"节课由您代上，不要忘了哦");
				Map<String,Object> result = smartCampusApiService.sendMsg(actualNode.getSchoolId(), data);
				System.out.println(result.get("msg"));
			}
		}
	}
}
